package com.situ.be.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.test.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.situ.be.service.BeOrderuserService;
import com.situ.be.entity.BeOrderuser;

import java.util.List;

/**
 * BeOrderuser的路由接口服务
 * 
 * @author胡文
 *
 */
//
@Api(description = "BeOrderuser模块接口说明")
@RestController
public class BeOrderuserController {

	/** BeOrderuserService服务 */
	@Autowired
	private BeOrderuserService beOrderuserService;
	
	/**
	 * 查询所有BeOrderuser数据的方法
	 * @param value
	 * @return
	 */
@ApiOperation("查询所有BeOrderuser数据的方法")
	@GetMapping(value = "/BeOrderuser/query", produces = {"application/json;charset=UTF-8"})
	public ResponseData query(BeOrderuser value) {

		return ResponseData.ok().putDataValue("list",beOrderuserService.find(value));
	}
	
	/**
	 * 通过id查询BeOrderuser数据的方法
	 * 
	 * @return
	 */
     @ApiOperation("通过id查询BeOrderuser数据的方法")
	@GetMapping(value = "/BeOrderuser/queryById/{id}", produces = {"application/json;charset=UTF-8"})
	public ResponseData queryById(@PathVariable(name="id") Integer id) {
		 return ResponseData.ok().putDataValue("obj",beOrderuserService.findOne(id));
	}
	
	/**
	 * 插入BeOrderuser属性不为空的数据方法
	 * 
	 * @return
	 */
@ApiOperation("插入BeOrderuser属性不为空的数据方法")
	@PostMapping(value = "/BeOrderuser/save")
	public ResponseData save(BeOrderuser value) {
		return ResponseData.ok().putDataValue("obj", beOrderuserService.saveNotNull(value));
	}
	
	/**
	 * 更新BeOrderuser属性不为空的数据方法
	 * 
	 * @return
	 */
     @ApiOperation("更新BeOrderuser属性不为空的数据方法")
	@PostMapping(value = "/BeOrderuser/update", produces = {"application/json;charset=UTF-8"})
	public ResponseData update(BeOrderuser value) {
		return ResponseData.ok().putDataValue("obj",beOrderuserService.updateNotNullById(value));
	}

	/**
	 * 通过id删除BeOrderuser数据方法
	 * 
	 * @return
	 */
     @ApiOperation("通过id删除BeOrderuser数据方法")
	@PostMapping(value = "/BeOrderuser/delById/{id}", produces = {"application/json;charset=UTF-8"})
	public ResponseData delById(@PathVariable(name="id") Integer id) {
		return ResponseData.ok().putDataValue("obj",beOrderuserService.deleteById(id));
	}


    //带分页的查询全部
    @ApiOperation("带分页的条件模糊查询")
    @GetMapping(value = "/BeOrderuser/queryPage", produces = {"application/json;charset=UTF-8"})
    public ResponseData queryPage(BeOrderuser value,
								  @ApiParam("第几页")
                             @RequestParam(defaultValue = "1",required = false) int pageNum ,
								  @ApiParam("每页多少条")
                             @RequestParam(defaultValue = "10",required = false) int pageSize) {

	 PageHelper.startPage(pageNum, pageSize);
        List<BeOrderuser> list = beOrderuserService.find2(value);
    PageInfo pageInfo = new PageInfo<BeOrderuser>(list,7);
        return ResponseData.ok()
        .putDataValue("pageInfo",pageInfo);
   }

}
